<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<script type="text/javascript">
	function pass(exchangeId) {
		if(confirm("您确定要通过这个调换申请吗？")) {
			window.location="exchange?action=pass&exchangeId="+exchangeId;
		}
	}
	function reject(exchangeId) {
		if(confirm("您确定要驳回这个调换申请吗？")) {
			window.location="exchange?action=reject&exchangeId="+exchangeId;
		}
	}
	$(document).ready(function(){
		$("ul li:eq(2)").addClass("active");
		$('.dataTable').dataTable( {
			"oLanguage": {
				"sProcessing":   "处理中...",
				"sLengthMenu":   "_MENU_ 记录/页",
				"sZeroRecords":  "没有匹配的记录",
				"sInfo":         "显示第 _START_ 至 _END_ 项记录，共 _TOTAL_ 项",
				"sInfoEmpty":    "显示第 0 至 0 项记录，共 0 项",
				"sInfoFiltered": "(由 _MAX_ 项记录过滤)",
				"sInfoPostFix":  "",
				"sSearch":       "查找（所有信息）:",
				"sUrl":          ""
			},
			"bPaginate": true ,//该参数为是否显示分页
			"bLengthChange": false, //改变每页显示数据数量
			"bStateSave": true,
			"bFilter": true, //过滤功能
			"aoColumns": [
				null,
				null,
				null,
				null,
				null,
				null,
				{"asSorting":[]},
				{ "asSorting": [ ] }
			]
		});
		$("#DataTables_Table_0_wrapper .row-fluid").remove();
	});

	window.onload = function(){
		$("#DataTables_Table_0_wrapper .row-fluid").remove();
	};
</script>
<style type="text/css">
	.span6 {
		width:0px;
		height: 0px;
		padding-top: 0px;
		padding-bottom: 0px;
		margin-top: 0px;
		margin-bottom: 0px;
	}
</style>
<div class="data_list">
	<div class="data_list_title">
		调换申请
	</div>
	<form name="myForm" class="form-search" method="post" action="exchange?action=search" style="padding-bottom: 0px">
		<span class="data_search">
			<select id="searchType" name="searchType" style="width: 80px;">
				<option value="name">姓名</option>
			</select>
			&nbsp;<input id="searchText" name="searchText" type="text"  style="width:120px;height: 30px;" class="input-medium search-query" value="${searchText }">
			&nbsp;<button type="submit" class="btn btn-info" onkeydown="if(event.keyCode==13) myForm.submit()">搜索</button>
		</span>
	</form>
	<div>
		<table class="table table-striped table-bordered table-hover datatable">
			<thead>
			<tr>
				<th>姓名</th>
				<th>性别</th>
				<th>宿舍楼</th>
				<th>寝室</th>
				<th>调换原因</th>
				<th>调换日期</th>
				<th>调换状态</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
			<c:forEach  varStatus="i" var="exchange" items="${exchangeList}">
				<tr>
					<td>${exchange.userName}</td>
					<td>${exchange.sex}</td>
					<td>${exchange.buildName}</td>
					<td>${exchange.roomNum}</td>
					<td>${exchange.reason}</td>
					<td>${exchange.date}</td>
					<td>
						<c:choose>
							<c:when test="${exchange.status eq '已通过'}">
								<span class="btn btn-mini btn-success">${exchange.status}</span>
							</c:when>
							<c:when test="${exchange.status eq '审核中'}">
								<span class="btn btn-mini btn-info">${exchange.status}</span>
							</c:when>
							<c:otherwise>
								<span class="btn btn-mini btn-danger">${exchange.status}</span>
							</c:otherwise>
						</c:choose>
					</td>
					<td>
						<button class="btn btn-mini btn-success" type="button" onclick="pass(${exchange.id})">通过</button>
						<button class="btn btn-mini btn-danger" type="button" onclick="reject(${exchange.id})">驳回</button>
					</td>
				</tr>
			</c:forEach>
			</tbody>
		</table>
	</div>
	<div align="center"><font color="red">${error }</font></div>
	<div class="pagination pagination-centered">
		<ul>
			${pageCode }
		</ul>
	</div>
</div>